package com.jjyd.crlp.domain.entity;

import com.jjyd.crlp.domain.entity.type.LoginType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.joda.time.LocalDateTime;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * 用户登陆信息表 以及存放权限信息
 */
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Data
@EntityListeners(AuditingEntityListener.class)
@Table(name = "user_auth")
public class UserAuth {
    /**
     * id主键，自动递增
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id",columnDefinition = "int COMMENT '主键id'")
    private Integer id;

    /**
     * 用户的id
     */
    @Column(name = "user_id",columnDefinition = "int COMMENT '普通用户的id'")
    private Integer userId;


    /**
     * 登陆类型
     */
    @Column(name = "login_type",nullable = false,columnDefinition = "int COMMENT '登陆类型'")
    private LoginType loginType;

    /**
     * 标识符号
     */
    @Column(name = "identifier",nullable = false,columnDefinition = "varchar(255) COMMENT '标识符号'")
    private String identifier;

    /**
     * 登陆凭证
     */
    @Column(name = "credential",nullable = false,columnDefinition = "varchar(255) COMMENT '登陆凭证'")
    private String credential;



    /**
     * 是否删除，默认false
     */
    @Column(name = "remove",nullable = false,columnDefinition = "bit COMMENT '是否删除，默认false'")
    private Boolean remove = false;

    /**
     * 创建时间
     */
    @Column(name = "create_time",columnDefinition = "DATETIME COMMENT '创建的时间'")
    @CreatedDate
    private LocalDateTime createTime;

    /**
     * 最后一次更新时间
     */
    @Column(name = "update_time",columnDefinition = "DATETIME COMMENT '更新时间'")
    @LastModifiedDate
    private LocalDateTime updateTime;

}
